$(function(){
	chooseSeat();
})


var seatArr = new Array(100);
for(var i=0; i<100; i++){
	seatArr[i] = 0;
}

var test = function(){
	var seatStr = "0011001000001001101100101010010011010100101100110110000010010011001011000000100011000011011000001100";

// 生成二维数组存放id及flag
	for(var j=0; j<100; j++){
		if(seatStr[j] == "1"){
			seatArr[j] = 1;
		}
	}
}



var seatCard = Vue.component('seat-model',{
	props: ['sFlag','sLeft','sTop','sMark','sId'],
	template: '#tem-seat'
});

var seatList = new Vue({
	el: "#seat-list",
	data: {
		items: seatArr
	},
	methods: {
		getFlag: function(index){
			test();
			return this.items[index];
		},
		getLeft: function(index){
			var i = index%10;
			return (50*i+120)+'px';
		},
		getTop: function(index){
			var j = Math.floor(index/10);
			return (j*40)+'px';
		},
		getMark: function(index){
			if(this.items[index] == 1){
				return true;
			}else{
				return false;
			}
		},
		getSeatid: function(index){
			return index;
		}
	}
});

// 座位模板
Vue.component('seat-i',{
	template: '<a href="javascritp:;" class="seat-num">2排16座</a>'
});

var seatI = new Vue({
	el: '#seat-group'
});

// 选择座位
var chooseSeat = function(){
	$('.seat-cell:not(.seat-sold)').on('click',function(){
		if($(this).hasClass('seat-checked')){
			$(this).removeClass('seat-checked');
		}else{
			$(this).addClass('seat-checked');
			$('.no-set').css("display","none");
			$('.seat-tips').css("display","none");
			$('.seat-text').css("display","block");
			// $('.pew-group').append('<seat-i></seat-i>');
			$('.pew-group').append('<a href="javascritp:;" class="seat-num"></a>');
			$('.seat-num:last-child').text($(this).attr('data-name'));
			$('.seat-num:last-child').attr('sid',$(this).attr('data-seatid'));
		}
	}),

	$('.seat-num').on('click',function(){
		// $('.seat-cell[]')
		$('.pew-group').remove($(this));
	})
};
